package cms.service.upload;

import cms.bean.setting.EditorTag;
import cms.bean.user.AccessUser;
import cms.bean.user.ResourceEnum;
import cms.common.data.ApiResultCode;
import cms.common.exception.ServiceException;
import org.springframework.stereotype.Service;

@Service("mediaBeService")
public class MediaBeService extends BaseFileService implements FileService {
    @Override
    protected UpFileType uploadHander(String model, AccessUser accessUser) {
        //是否有当前功能操作权限
        boolean isPermission = userRoleManage.isPermission(ResourceEnum._2004000, null, accessUser);
        if (isPermission) {
            EditorTag editorTag = getEditorTag(model);
            if (editorTag.isUploadVideo()) {//允许上传视频
                return new UpFileType(editorTag.getVideoFormat(), editorTag.getVideoSize());
            }
        }
        throw new ServiceException(ApiResultCode.NO_PERMISSION.setMessage("上传视频权限不足"));
    }
}
